package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.data.EatShowUserInfo;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by Administrater on 2015/12/7.
 */
public class LiveOverTask extends CouponHttpBaseTask {

    private String mVideoId;
    private String mType;

    public LiveOverTask(String vid){
        super();
        mVideoId =vid;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        JSONObject json = response.getBody();
        EatShowUserInfo stopinfo = null;
        if (json != null) {
            stopinfo = JSON.parseObject(json.toString(), EatShowUserInfo.class);
        }
        notifyTaskCompleted(TaskResultCode.SUCCESS, stopinfo);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest();
            JSONObject json = new JSONObject();
            json.put("vid", mVideoId);
            request.setData(json.toString());
            request.setApiNo(ApiNo.LIVEOVER);
            addRequest(request);
        }
    }

}
